﻿class Test {
    static void Main(string[] args) {
        int shapeNum = 10;
        Random random = new();
        int sideRange = 100;
        var shapes = ShapeFactory.CreateRandomShapes(shapeNum, sideRange);
        int legalShapeNum = 0;

        double areaSum = 0;
        for (int i = 0; i < shapes.Length; i++) {
            double area = 0;
            try {
                area = shapes[i].GetArea();
            }
            catch (ArgumentException e) {
                Console.WriteLine($"Shape {i} {e.Message}");
                continue;
            }
            Console.WriteLine($"Shape {i} Area:{area}");
            areaSum += area;
            legalShapeNum++;
        }
        Console.WriteLine($"一共生成{legalShapeNum}个有效图形");
        Console.WriteLine($"AreaSum = {areaSum}");
    }
}